package com.sun.hunk.hibernate.domain.impl;

import com.sun.hunk.hibernate.domain.Client;
import com.sun.hunk.hibernate.domain.GenericCode;
import com.sun.hunk.hibernate.domain.Item;
import com.sun.hunk.hibernate.domain.ItemCharge;
import com.sun.hunk.hibernate.domain.Payment;
import com.sun.hunk.hibernate.domain.Sales;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author sunil
 */
@Entity
@Table(name = "sales")
public class SalesImpl implements Sales {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "sales_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date salesDate;
    @JoinColumn(name = "item_id", referencedColumnName = "id")
    @ManyToOne(targetEntity=ItemImpl.class)
    private Item item;
    @Column(name = "quantity")
    private Integer quantity;
    @Column(name = "amount")
    private Double amount;
    @Column(name = "paid_amount")
    private Double paidAmount;
    @Column(name = "due_amount")
    private Double dueAmount;
    @Column(name = "return_goods")
    private String returnGoods;
    @Column(name = "return_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date returnDate;
    @Column(name = "sales_tax")
    private String salesTax;
    @Column(name = "sales_tax_percentage")
    private String salesTaxPercentage;
    @OneToMany(mappedBy = "sales",targetEntity=ItemChargeImpl.class, cascade=CascadeType.ALL)
    private List<ItemCharge> charges;
    @JoinColumn(name = "payment_mode_id", referencedColumnName = "id")
    @ManyToOne(targetEntity=GenericCodeImpl.class)
    private GenericCode paymentMode;
    @JoinColumn(name = "payment_id", referencedColumnName = "id")
    @ManyToOne(targetEntity=PaymentImpl.class, cascade=CascadeType.ALL)
    private Payment payment;
    @JoinColumn(name = "sales_to", referencedColumnName = "id")
    @OneToOne(targetEntity=ClientImpl.class, cascade=CascadeType.ALL)
    private Client salesTo;

    public SalesImpl() {
    }

    public SalesImpl(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getSalesDate() {
        return salesDate;
    }

    public void setSalesDate(Date salesDate) {
        this.salesDate = salesDate;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Double getPaidAmount() {
        return paidAmount;
    }

    public void setPaidAmount(Double paidAmount) {
        this.paidAmount = paidAmount;
    }

    public Double getDueAmount() {
        return dueAmount;
    }

    public void setDueAmount(Double dueAmount) {
        this.dueAmount = dueAmount;
    }

    public String getReturnGoods() {
        return returnGoods;
    }

    public void setReturnGoods(String returnGoods) {
        this.returnGoods = returnGoods;
    }

    public Date getReturnDate() {
        return returnDate;
    }

    public void setReturnDate(Date returnDate) {
        this.returnDate = returnDate;
    }

    public String getSalesTax() {
        return salesTax;
    }

    public void setSalesTax(String salesTax) {
        this.salesTax = salesTax;
    }

    public String getSalesTaxPercentage() {
        return salesTaxPercentage;
    }

    public void setSalesTaxPercentage(String salesTaxPercentage) {
        this.salesTaxPercentage = salesTaxPercentage;
    }
    
    public Payment getPayment() {
        return payment;
    }

    public void setPayment(Payment payment) {
        this.payment = payment;
    }

    public List<ItemCharge> getCharges() {
        return charges;
    }

    public void setCharges(List<ItemCharge> charges) {
        this.charges = charges;
    }

    public GenericCode getPaymentMode() {
        return paymentMode;
    }

    public void setPaymentMode(GenericCode paymentMode) {
        this.paymentMode = paymentMode;
    }

    public Client getSalesTo() {
        return salesTo;
    }

    public void setSalesTo(Client salesTo) {
        this.salesTo = salesTo;
    }


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SalesImpl)) {
            return false;
        }
        SalesImpl other = (SalesImpl) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sun.hunk.hibernate.domain.Sales[id=" + id + "]";
    }

}
